#include <stdio.h>
#include <flgrCoreData.h>
#include <flgrCoreDataIO.h>
#include <flgrCoreCopy.h>
#include <flgrArith.h>
#include <flgrArithComplex.h>
#include "../macro.h"




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Inf(dtype)						\
									\
  dtype rawsrc1[] = {0, 1, 2, 2, 3, 0, 0, 0, 3, 0};			\
									\
  dtype rawsrc2[] = {0, 5, 6, 7, 8, 0, 0, 0, 9, 0};			\
									\
  dtype rawref[]  = {0, 1, 2, 2, 3, 0, 0, 0, 3, 0};			\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_inf(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_inf_str(dat2, datsrc1, "4");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Inf_fgUINT8(void) {
  tstArith1d_Inf(fgUINT8);
}
int testArith1d_Inf_fgUINT16(void) {
  tstArith1d_Inf(fgUINT16);
}
int testArith1d_Inf_fgUINT32(void) {
  tstArith1d_Inf(fgUINT32);
}
int testArith1d_Inf_fgINT8(void) {
  tstArith1d_Inf(fgINT8);
}
int testArith1d_Inf_fgINT16(void) {
  tstArith1d_Inf(fgINT16);
}
int testArith1d_Inf_fgINT32(void) {
  tstArith1d_Inf(fgINT32);
}
int testArith1d_Inf_fgFLOAT32(void) {
  tstArith1d_Inf(fgFLOAT32);
}
int testArith1d_Inf_fgFLOAT64(void) {
  tstArith1d_Inf(fgFLOAT64);
}
int testArith1d_Inf_fgBIT(void) {
  tstArith1d_Inf(fgBIT);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_spp3_Inf(dtype)					\
									\
  dtype rawsrc1[] = {0,0,0,  1,1,1,  2,2,2,  2,2,2,  3,3,3,  0,0,0,  0,0,0,  0,0,0,  3,3,3,  0,0,0}; \
									\
  dtype rawsrc2[] = {0,0,0,  5,5,5,  6,6,6,  7,7,7,  8,8,8,  0,0,0,  0,0,0,  0,0,0,  9,9,9,  0,1,2}; \
									\
  dtype rawref[]  = {0,0,0,  1,1,1,  2,2,2,  2,2,2,  3,3,3,  0,0,0,  0,0,0,  0,0,0,  3,3,3,  0,0,0}; \
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Type type = flgr_get_type_from_string(#dtype);			\
  FLGR_Ret ret;								\
									\
									\
  datsrc1 = flgr1d_create_signal(10, 3, type);				\
  datsrc2 = flgr1d_create_signal(10, 3, type);				\
  datref  = flgr1d_create_signal(10, 3, type);				\
  dat     = flgr1d_create_signal(10, 3, type);				\
  dat2    = flgr1d_create_signal(10, 3, type);				\
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_inf(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_inf_str(dat2, datsrc1, "4 3 5");		\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Inf_spp3_fgUINT8(void) {
  tstArith1d_spp3_Inf(fgUINT8);
}
int testArith1d_Inf_spp3_fgUINT16(void) {
  tstArith1d_spp3_Inf(fgUINT16);
}
int testArith1d_Inf_spp3_fgUINT32(void) {
  tstArith1d_spp3_Inf(fgUINT32);
}
int testArith1d_Inf_spp3_fgINT8(void) {
  tstArith1d_spp3_Inf(fgINT8);
}
int testArith1d_Inf_spp3_fgINT16(void) {
  tstArith1d_spp3_Inf(fgINT16);
}
int testArith1d_Inf_spp3_fgINT32(void) {
  tstArith1d_spp3_Inf(fgINT32);
}
int testArith1d_Inf_spp3_fgFLOAT32(void) {
  tstArith1d_spp3_Inf(fgFLOAT32);
}
int testArith1d_Inf_spp3_fgFLOAT64(void) {
  tstArith1d_spp3_Inf(fgFLOAT64);
}
int testArith1d_Inf_spp3_fgBIT(void) {
  tstArith1d_spp3_Inf(fgBIT);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Sup(dtype)						\
									\
  dtype rawsrc1[] = {0, 1, 2, 2, 3, 0, 0, 0, 3, 0};			\
									\
  dtype rawsrc2[] = {0, 5, 6, 7, 8, 0, 0, 0, 9, 0};			\
									\
  dtype rawref[]  = {0, 5, 6, 7, 8, 0, 0, 0, 9, 0};			\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_sup(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_sup_str(dat2, datsrc1, "0");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Sup_fgUINT8(void) {
  tstArith1d_Sup(fgUINT8);
}
int testArith1d_Sup_fgUINT16(void) {
  tstArith1d_Sup(fgUINT16);
}
int testArith1d_Sup_fgUINT32(void) {
  tstArith1d_Sup(fgUINT32);
}
int testArith1d_Sup_fgINT8(void) {
  tstArith1d_Sup(fgINT8);
}
int testArith1d_Sup_fgINT16(void) {
  tstArith1d_Sup(fgINT16);
}
int testArith1d_Sup_fgINT32(void) {
  tstArith1d_Sup(fgINT32);
}
int testArith1d_Sup_fgFLOAT32(void) {
  tstArith1d_Sup(fgFLOAT32);
}
int testArith1d_Sup_fgFLOAT64(void) {
  tstArith1d_Sup(fgFLOAT64);
}
int testArith1d_Sup_fgBIT(void) {
  tstArith1d_Sup(fgBIT);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_And(dtype, ref1,ref2,ref3,ref4)			\
									\
  dtype rawsrc1[] = {0, 1, 4, 2};					\
									\
  dtype rawsrc2[] = {0,16,16, 2};					\
									\
  dtype rawref[]  = {ref1,ref2,ref3,ref4};				\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_and(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_and_str(dat2, datsrc1, "2");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_And_fgUINT8(void) {
  tstArith1d_And(fgUINT8,0,0,0,2);
}
int testArith1d_And_fgUINT16(void) {
  tstArith1d_And(fgUINT16,0,0,0,2);
}
int testArith1d_And_fgUINT32(void) {
  tstArith1d_And(fgUINT32,0,0,0,2);
}
int testArith1d_And_fgINT8(void) {
  tstArith1d_And(fgINT8,0,0,0,2);
}
int testArith1d_And_fgINT16(void) {
  tstArith1d_And(fgINT16,0,0,0,2);
}
int testArith1d_And_fgINT32(void) {
  tstArith1d_And(fgINT32,0,0,0,2);
}
int testArith1d_And_fgBIT(void) {
  tstArith1d_And(fgBIT,0,1,1,1);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Or(dtype, ref1,ref2,ref3,ref4)			\
									\
  dtype rawsrc1[] = {0, 1, 0, 2};					\
									\
  dtype rawsrc2[] = {0, 2, 2, 2};					\
									\
  dtype rawref[]  = {ref1,ref2,ref3,ref4};				\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_or(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_or_str(dat2, datsrc1, "2");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Or_fgUINT8(void) {
  tstArith1d_Or(fgUINT8,0,3,2,2);
}
int testArith1d_Or_fgUINT16(void) {
  tstArith1d_Or(fgUINT16,0,3,2,2);
}
int testArith1d_Or_fgUINT32(void) {
  tstArith1d_Or(fgUINT32,0,3,2,2);
}
int testArith1d_Or_fgINT8(void) {
  tstArith1d_Or(fgINT8,0,3,2,2);
}
int testArith1d_Or_fgINT16(void) {
  tstArith1d_Or(fgINT16,0,3,2,2);
}
int testArith1d_Or_fgINT32(void) {
  tstArith1d_Or(fgINT32,0,3,2,2);
}
int testArith1d_Or_fgBIT(void) {
  tstArith1d_Or(fgBIT,0,1,1,1);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Xor(dtype, ref1,ref2,ref3,ref4)			\
									\
  dtype rawsrc1[] = {0, 1, 0, 2};					\
									\
  dtype rawsrc2[] = {0, 2, 2, 2};					\
									\
  dtype rawref[]  = {ref1,ref2,ref3,ref4};				\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_xor(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_xor_str(dat2, datsrc1, "2");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Xor_fgUINT8(void) {
  tstArith1d_Xor(fgUINT8,0,3,2,0);
}
int testArith1d_Xor_fgUINT16(void) {
  tstArith1d_Xor(fgUINT16,0,3,2,0);
}
int testArith1d_Xor_fgUINT32(void) {
  tstArith1d_Xor(fgUINT32,0,3,2,0);
}
int testArith1d_Xor_fgINT8(void) {
  tstArith1d_Xor(fgINT8,0,3,2,0);
}
int testArith1d_Xor_fgINT16(void) {
  tstArith1d_Xor(fgINT16,0,3,2,0);
}
int testArith1d_Xor_fgINT32(void) {
  tstArith1d_Xor(fgINT32,0,3,2,0);
}
int testArith1d_Xor_fgBIT(void) {
  tstArith1d_Xor(fgBIT,0,0,1,0);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Multsat(dtype,csat)					\
									\
  dtype rawsrc1[] = {0, 5, 6, 7, 8, csat, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {0, 2, 2, 2, 2, 2, 0, 0, 2, 0};			\
									\
  dtype rawref[]  = {0,10,12,14,16,MAX_##dtype, 0, 0,18, 0};		\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_multsat(dat, datsrc1, datsrc2);			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_multsat_str(dat2, datsrc1, "2");		\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Multsat_fgUINT8(void) {
  tstArith1d_Multsat(fgUINT8,200U);
}
int testArith1d_Multsat_fgUINT16(void) {
  tstArith1d_Multsat(fgUINT16,40000U);
}
int testArith1d_Multsat_fgUINT32(void) {
  tstArith1d_Multsat(fgUINT32,3000000000U);
}
int testArith1d_Multsat_fgINT8(void) {
  tstArith1d_Multsat(fgINT8,100);
}
int testArith1d_Multsat_fgINT16(void) {
  tstArith1d_Multsat(fgINT16,20000);
}
int testArith1d_Multsat_fgINT32(void) {
  tstArith1d_Multsat(fgINT32,2000000000);
}






/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Addsat(dtype,csat1,csat2)				\
									\
  dtype rawsrc1[] = {0, 5, 6, 7, 8, csat1, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {0, 2, 2, 2, 2, csat2, 0, 0, 2, 0};			\
									\
  dtype rawref[]  = {0, 7, 8, 9,10,MAX_##dtype, 0, 0,11, 0};		\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_addsat(dat, datsrc1, datsrc2);			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_addsat_str(dat2, datsrc1, #csat2);		\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Addsat_fgUINT8(void) {
  tstArith1d_Addsat(fgUINT8,200,200);
}
int testArith1d_Addsat_fgUINT16(void) {
  tstArith1d_Addsat(fgUINT16,40000,40000);
}
int testArith1d_Addsat_fgUINT32(void) {
  tstArith1d_Addsat(fgUINT32,3000000000U,3000000000U);
}
int testArith1d_Addsat_fgINT8(void) {
  tstArith1d_Addsat(fgINT8,100,100);
}
int testArith1d_Addsat_fgINT16(void) {
  tstArith1d_Addsat(fgINT16,20000,20000);
}
int testArith1d_Addsat_fgINT32(void) {
  tstArith1d_Addsat(fgINT32,2000000000,2000000000);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Subsat(dtype,csat1,csat2)				\
									\
  dtype rawsrc1[] = {0, 5, 6, 7, 8, csat1, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {0, 2, 2, 2, 2, csat2, 0, 0, 2, 0};			\
									\
  dtype rawref[]  = {0, 3, 4, 5, 6,MIN_##dtype, 0, 0,7, 0};		\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_subsat(dat, datsrc1, datsrc2);			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_subsat_str(dat2, datsrc1, #csat2);		\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Subsat_fgUINT8(void) {
  tstArith1d_Subsat(fgUINT8,200,220);
}
int testArith1d_Subsat_fgUINT16(void) {
  tstArith1d_Subsat(fgUINT16,40000,42000);
}
int testArith1d_Subsat_fgUINT32(void) {
  tstArith1d_Subsat(fgUINT32,3000000000U,3200000000U);
}
int testArith1d_Subsat_fgINT8(void) {
  tstArith1d_Subsat(fgINT8,-100,100);
}
int testArith1d_Subsat_fgINT16(void) {
  tstArith1d_Subsat(fgINT16,-20000,20000);
}
int testArith1d_Subsat_fgINT32(void) {
  tstArith1d_Subsat(fgINT32,-2000000000,2000000000);
}






/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Div(dtype)						\
									\
  dtype rawsrc1[] = {0, 9, 6, 3, 9,21, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {1, 3, 3, 3, 3, 3, 1, 1, 3, 1};			\
									\
  dtype rawref[]  = {0, 3, 2, 1, 3, 7, 0, 0, 3, 0};			\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_div(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_div_str(dat2, datsrc1, "3");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Div_fgUINT8(void) {
  tstArith1d_Div(fgUINT8);
}
int testArith1d_Div_fgUINT16(void) {
  tstArith1d_Div(fgUINT16);
}
int testArith1d_Div_fgUINT32(void) {
  tstArith1d_Div(fgUINT32);
}
int testArith1d_Div_fgINT8(void) {
  tstArith1d_Div(fgINT8);
}
int testArith1d_Div_fgINT16(void) {
  tstArith1d_Div(fgINT16);
}
int testArith1d_Div_fgINT32(void) {
  tstArith1d_Div(fgINT32);
}
int testArith1d_Div_fgFLOAT32(void) {
  tstArith1d_Div(fgFLOAT32);
}
int testArith1d_Div_fgFLOAT64(void) {
  tstArith1d_Div(fgFLOAT64);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Mult(dtype)						\
									\
  dtype rawsrc1[] = {0, 9, 6, 3, 9,21, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {1, 3, 3, 3, 3, 3, 1, 1, 3, 1};			\
									\
  dtype rawref[]  = {0,27,18, 9,27,63, 0, 0,27, 0};			\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_mult(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_mult_str(dat2, datsrc1, "3");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Mult_fgUINT8(void) {
  tstArith1d_Mult(fgUINT8);
}
int testArith1d_Mult_fgUINT16(void) {
  tstArith1d_Mult(fgUINT16);
}
int testArith1d_Mult_fgUINT32(void) {
  tstArith1d_Mult(fgUINT32);
}
int testArith1d_Mult_fgINT8(void) {
  tstArith1d_Mult(fgINT8);
}
int testArith1d_Mult_fgINT16(void) {
  tstArith1d_Mult(fgINT16);
}
int testArith1d_Mult_fgINT32(void) {
  tstArith1d_Mult(fgINT32);
}
int testArith1d_Mult_fgFLOAT32(void) {
  tstArith1d_Mult(fgFLOAT32);
}
int testArith1d_Mult_fgFLOAT64(void) {
  tstArith1d_Mult(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Add(dtype)						\
									\
  dtype rawsrc1[] = {0, 9, 6, 3, 9,21, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {1, 3, 3, 3, 3, 3, 1, 1, 3, 1};			\
									\
  dtype rawref[]  = {1,12, 9, 6,12,24, 1, 1,12, 1};			\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_add(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_add_str(dat2, datsrc1, "3");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Add_fgUINT8(void) {
  tstArith1d_Add(fgUINT8);
}
int testArith1d_Add_fgUINT16(void) {
  tstArith1d_Add(fgUINT16);
}
int testArith1d_Add_fgUINT32(void) {
  tstArith1d_Add(fgUINT32);
}
int testArith1d_Add_fgINT8(void) {
  tstArith1d_Add(fgINT8);
}
int testArith1d_Add_fgINT16(void) {
  tstArith1d_Add(fgINT16);
}
int testArith1d_Add_fgINT32(void) {
  tstArith1d_Add(fgINT32);
}
int testArith1d_Add_fgFLOAT32(void) {
  tstArith1d_Add(fgFLOAT32);
}
int testArith1d_Add_fgFLOAT64(void) {
  tstArith1d_Add(fgFLOAT64);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Sub(dtype)						\
									\
  dtype rawsrc1[] = {5, 9, 6, 3, 9,21, 5, 5, 9, 5};			\
									\
  dtype rawsrc2[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3};			\
									\
  dtype rawref[]  = {2, 6, 3, 0, 6,18, 2, 2, 6, 2};			\
									\
									\
  FLGR_Data1D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_sub(dat, datsrc1, datsrc2);				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  ret=flgr1d_arith_const_sub_str(dat2, datsrc1, "3");			\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datsrc2);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
  flgr1d_destroy(dat2);							\
									\
  return 2


int testArith1d_Sub_fgUINT8(void) {
  tstArith1d_Sub(fgUINT8);
}
int testArith1d_Sub_fgUINT16(void) {
  tstArith1d_Sub(fgUINT16);
}
int testArith1d_Sub_fgUINT32(void) {
  tstArith1d_Sub(fgUINT32);
}
int testArith1d_Sub_fgINT8(void) {
  tstArith1d_Sub(fgINT8);
}
int testArith1d_Sub_fgINT16(void) {
  tstArith1d_Sub(fgINT16);
}
int testArith1d_Sub_fgINT32(void) {
  tstArith1d_Sub(fgINT32);
}
int testArith1d_Sub_fgFLOAT32(void) {
  tstArith1d_Sub(fgFLOAT32);
}
int testArith1d_Sub_fgFLOAT64(void) {
  tstArith1d_Sub(fgFLOAT64);
}








/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Atan(dtype)						\
									\
  dtype rawsrc1[] = {0, 10, 20, 20, 30, 0, 0, 0, 30, 0};		\
									\
  dtype rawref[]  = {0,147,152,152,153, 0, 0, 0,153, 0};		\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_atan(dat, datsrc1);					\
  flgr1d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Atan_fgFLOAT32(void) {
  tstArith1d_Atan(fgFLOAT32);
}
int testArith1d_Atan_fgFLOAT64(void) {
  tstArith1d_Atan(fgFLOAT64);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Asin(dtype)						\
									\
  dtype rawsrc1[] = {0, 0.2, 0.3, 0.4, 0.5, 0, 0, 0, 0.2, 0};		\
									\
  dtype rawref[]  = {0,  20,  30,  41,  52, 0, 0, 0,  20, 0};		\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_asin(dat, datsrc1);					\
  flgr1d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Asin_fgFLOAT32(void) {
  tstArith1d_Asin(fgFLOAT32);
}
int testArith1d_Asin_fgFLOAT64(void) {
  tstArith1d_Asin(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Acos(dtype)						\
									\
  dtype rawsrc1[] = {  0, 0.2, 0.3, 0.4, 0.5,   0,   0,   0, 0.2,   0};	\
									\
  dtype rawref[]  = {157, 136, 126, 115, 104, 157, 157, 157, 136, 157};	\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_acos(dat, datsrc1);					\
  flgr1d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Acos_fgFLOAT32(void) {
  tstArith1d_Acos(fgFLOAT32);
}
int testArith1d_Acos_fgFLOAT64(void) {
  tstArith1d_Acos(fgFLOAT64);
}








/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Tan(dtype)						\
									\
  dtype rawsrc1[] = {0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0};		\
									\
  dtype rawref[]  = {0,  10, 20,   30,  42, 0, 0, 0,  54, 0};		\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_tan(dat, datsrc1);					\
  flgr1d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Tan_fgFLOAT32(void) {
  tstArith1d_Tan(fgFLOAT32);
}
int testArith1d_Tan_fgFLOAT64(void) {
  tstArith1d_Tan(fgFLOAT64);
}






/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Sin(dtype)						\
									\
  dtype rawsrc1[] = {0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0};		\
									\
  dtype rawref[]  = {0,   9,  19,  29,  38, 0, 0, 0,  47, 0};		\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_sin(dat, datsrc1);					\
  flgr1d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Sin_fgFLOAT32(void) {
  tstArith1d_Sin(fgFLOAT32);
}
int testArith1d_Sin_fgFLOAT64(void) {
  tstArith1d_Sin(fgFLOAT64);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Cos(dtype)						\
							 		\
  dtype rawsrc1[] = {  0, 0.1, 0.2, 0.3, 0.4,   0,   0,   0, 0.5,   0};	\
									\
  dtype rawref[]  = {100,  99,  98,  95,  92, 100, 100, 100,  87, 100};	\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_cos(dat, datsrc1);					\
  flgr1d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Cos_fgFLOAT32(void) {
  tstArith1d_Cos(fgFLOAT32);
}
int testArith1d_Cos_fgFLOAT64(void) {
  tstArith1d_Cos(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Floor(dtype)						\
							 		\
  dtype rawsrc1[] = {1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5};	\
									\
  dtype rawref[]  = {1,     9,   5,   3,   9,    8 ,7, 0,   0,   8};	\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_floor(dat, datsrc1);					\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Floor_fgFLOAT32(void) {
  tstArith1d_Floor(fgFLOAT32);
}
int testArith1d_Floor_fgFLOAT64(void) {
  tstArith1d_Floor(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith1d_Ceil(dtype)						\
							 		\
  dtype rawsrc1[] = {1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5};	\
									\
  dtype rawref[]  = {  2,  10,   6,   4,  10,    9 ,7, 0,   1,   9};	\
									\
									\
  FLGR_Data1D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr1d_create_signal(10,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr1d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr1d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr1d_arith_ceil(dat, datsrc1);					\
  check_and_display_data1d(datref, dat, ret);				\
									\
  flgr1d_destroy(datsrc1);						\
  flgr1d_destroy(datref);						\
  flgr1d_destroy(dat);							\
									\
  return 1


int testArith1d_Ceil_fgFLOAT32(void) {
  tstArith1d_Ceil(fgFLOAT32);
}
int testArith1d_Ceil_fgFLOAT64(void) {
  tstArith1d_Ceil(fgFLOAT64);
}

















/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Inf(dtype)						\
									\
  dtype rawsrc1[] = {0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0};			\
									\
  dtype rawsrc2[] = {0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0};			\
									\
  dtype rawref[]  = {0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0};			\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_inf(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_inf_str(dat2, datsrc1, "4");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Inf_fgUINT8(void) {
  tstArith2d_Inf(fgUINT8);
}
int testArith2d_Inf_fgUINT16(void) {
  tstArith2d_Inf(fgUINT16);
}
int testArith2d_Inf_fgUINT32(void) {
  tstArith2d_Inf(fgUINT32);
}
int testArith2d_Inf_fgINT8(void) {
  tstArith2d_Inf(fgINT8);
}
int testArith2d_Inf_fgINT16(void) {
  tstArith2d_Inf(fgINT16);
}
int testArith2d_Inf_fgINT32(void) {
  tstArith2d_Inf(fgINT32);
}
int testArith2d_Inf_fgFLOAT32(void) {
  tstArith2d_Inf(fgFLOAT32);
}
int testArith2d_Inf_fgFLOAT64(void) {
  tstArith2d_Inf(fgFLOAT64);
}
int testArith2d_Inf_fgBIT(void) {
  tstArith2d_Inf(fgBIT);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Sup(dtype)						\
									\
  dtype rawsrc1[] = {0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0,			\
		     0, 1, 2, 2, 3, 0, 0, 0, 3, 0};			\
									\
  dtype rawsrc2[] = {0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0};			\
									\
  dtype rawref[]  = {0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, 0, 0, 0, 9, 0};			\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_sup(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_sup_str(dat2, datsrc1, "0");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Sup_fgUINT8(void) {
  tstArith2d_Sup(fgUINT8);
}
int testArith2d_Sup_fgUINT16(void) {
  tstArith2d_Sup(fgUINT16);
}
int testArith2d_Sup_fgUINT32(void) {
  tstArith2d_Sup(fgUINT32);
}
int testArith2d_Sup_fgINT8(void) {
  tstArith2d_Sup(fgINT8);
}
int testArith2d_Sup_fgINT16(void) {
  tstArith2d_Sup(fgINT16);
}
int testArith2d_Sup_fgINT32(void) {
  tstArith2d_Sup(fgINT32);
}
int testArith2d_Sup_fgFLOAT32(void) {
  tstArith2d_Sup(fgFLOAT32);
}
int testArith2d_Sup_fgFLOAT64(void) {
  tstArith2d_Sup(fgFLOAT64);
}
int testArith2d_Sup_fgBIT(void) {
  tstArith2d_Sup(fgBIT);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_And(dtype, ref1,ref2,ref3,ref4)			\
									\
  dtype rawsrc1[] = {0, 1, 4, 2,					\
		     0, 1, 4, 2,					\
		     0, 1, 4, 2,					\
		     0, 1, 4, 2};					\
									\
  dtype rawsrc2[] = {0,16,16, 2,					\
		     0,16,16, 2,					\
		     0,16,16, 2,					\
		     0,16,16, 2};					\
									\
  dtype rawref[]  = {ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4};				\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_and(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_and_str(dat2, datsrc1, "2");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_And_fgUINT8(void) {
  tstArith2d_And(fgUINT8,0,0,0,2);
}
int testArith2d_And_fgUINT16(void) {
  tstArith2d_And(fgUINT16,0,0,0,2);
}
int testArith2d_And_fgUINT32(void) {
  tstArith2d_And(fgUINT32,0,0,0,2);
}
int testArith2d_And_fgINT8(void) {
  tstArith2d_And(fgINT8,0,0,0,2);
}
int testArith2d_And_fgINT16(void) {
  tstArith2d_And(fgINT16,0,0,0,2);
}
int testArith2d_And_fgINT32(void) {
  tstArith2d_And(fgINT32,0,0,0,2);
}
int testArith2d_And_fgBIT(void) {
  tstArith2d_And(fgBIT,0,1,1,1);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Or(dtype, ref1,ref2,ref3,ref4)			\
									\
  dtype rawsrc1[] = {0, 1, 0, 2,					\
		     0, 1, 0, 2,					\
		     0, 1, 0, 2,					\
		     0, 1, 0, 2};					\
									\
  dtype rawsrc2[] = {0, 2, 2, 2,					\
		     0, 2, 2, 2,					\
		     0, 2, 2, 2,					\
		     0, 2, 2, 2};					\
									\
  dtype rawref[]  = {ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4};				\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_or(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_or_str(dat2, datsrc1, "2");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Or_fgUINT8(void) {
  tstArith2d_Or(fgUINT8,0,3,2,2);
}
int testArith2d_Or_fgUINT16(void) {
  tstArith2d_Or(fgUINT16,0,3,2,2);
}
int testArith2d_Or_fgUINT32(void) {
  tstArith2d_Or(fgUINT32,0,3,2,2);
}
int testArith2d_Or_fgINT8(void) {
  tstArith2d_Or(fgINT8,0,3,2,2);
}
int testArith2d_Or_fgINT16(void) {
  tstArith2d_Or(fgINT16,0,3,2,2);
}
int testArith2d_Or_fgINT32(void) {
  tstArith2d_Or(fgINT32,0,3,2,2);
}
int testArith2d_Or_fgBIT(void) {
  tstArith2d_Or(fgBIT,0,1,1,1);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Xor(dtype, ref1,ref2,ref3,ref4)			\
									\
  dtype rawsrc1[] = {0, 1, 0, 2,					\
		     0, 1, 0, 2,					\
		     0, 1, 0, 2,					\
		     0, 1, 0, 2};					\
									\
  dtype rawsrc2[] = {0, 2, 2, 2,					\
		     0, 2, 2, 2,					\
		     0, 2, 2, 2,					\
		     0, 2, 2, 2};					\
									\
  dtype rawref[]  = {ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4,				\
		     ref1,ref2,ref3,ref4};				\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(4,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_xor(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_xor_str(dat2, datsrc1, "2");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Xor_fgUINT8(void) {
  tstArith2d_Xor(fgUINT8,0,3,2,0);
}
int testArith2d_Xor_fgUINT16(void) {
  tstArith2d_Xor(fgUINT16,0,3,2,0);
}
int testArith2d_Xor_fgUINT32(void) {
  tstArith2d_Xor(fgUINT32,0,3,2,0);
}
int testArith2d_Xor_fgINT8(void) {
  tstArith2d_Xor(fgINT8,0,3,2,0);
}
int testArith2d_Xor_fgINT16(void) {
  tstArith2d_Xor(fgINT16,0,3,2,0);
}
int testArith2d_Xor_fgINT32(void) {
  tstArith2d_Xor(fgINT32,0,3,2,0);
}
int testArith2d_Xor_fgBIT(void) {
  tstArith2d_Xor(fgBIT,0,0,1,0);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Multsat(dtype,csat)					\
									\
  dtype rawsrc1[] = {0, 5, 6, 7, 8, csat, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {0, 2, 2, 2, 2, 2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, 2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, 2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, 2, 0, 0, 2, 0};			\
									\
  dtype rawref[]  = {0,10,12,14,16,MAX_##dtype, 0, 0,18, 0,		\
		     0,10,12,14,16,MAX_##dtype, 0, 0,18, 0,		\
		     0,10,12,14,16,MAX_##dtype, 0, 0,18, 0,		\
		     0,10,12,14,16,MAX_##dtype, 0, 0,18, 0};		\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_multsat(dat, datsrc1, datsrc2);			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_multsat_str(dat2, datsrc1, "2");		\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Multsat_fgUINT8(void) {
  tstArith2d_Multsat(fgUINT8,200U);
}
int testArith2d_Multsat_fgUINT16(void) {
  tstArith2d_Multsat(fgUINT16,40000U);
}
int testArith2d_Multsat_fgUINT32(void) {
  tstArith2d_Multsat(fgUINT32,3000000000U);
}
int testArith2d_Multsat_fgINT8(void) {
  tstArith2d_Multsat(fgINT8,100);
}
int testArith2d_Multsat_fgINT16(void) {
  tstArith2d_Multsat(fgINT16,20000);
}
int testArith2d_Multsat_fgINT32(void) {
  tstArith2d_Multsat(fgINT32,2000000000);
}






/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Addsat(dtype,csat1,csat2)				\
									\
  dtype rawsrc1[] = {0, 5, 6, 7, 8, csat1, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat1, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat1, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat1, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {0, 2, 2, 2, 2, csat2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, csat2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, csat2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, csat2, 0, 0, 2, 0};			\
									\
  dtype rawref[]  = {0, 7, 8, 9,10,MAX_##dtype, 0, 0,11, 0,		\
		     0, 7, 8, 9,10,MAX_##dtype, 0, 0,11, 0,		\
		     0, 7, 8, 9,10,MAX_##dtype, 0, 0,11, 0,		\
		     0, 7, 8, 9,10,MAX_##dtype, 0, 0,11, 0};		\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_addsat(dat, datsrc1, datsrc2);			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_addsat_str(dat2, datsrc1, #csat2);		\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Addsat_fgUINT8(void) {
  tstArith2d_Addsat(fgUINT8,200,200);
}
int testArith2d_Addsat_fgUINT16(void) {
  tstArith2d_Addsat(fgUINT16,40000,40000);
}
int testArith2d_Addsat_fgUINT32(void) {
  tstArith2d_Addsat(fgUINT32,3000000000U,3000000000U);
}
int testArith2d_Addsat_fgINT8(void) {
  tstArith2d_Addsat(fgINT8,100,100);
}
int testArith2d_Addsat_fgINT16(void) {
  tstArith2d_Addsat(fgINT16,20000,20000);
}
int testArith2d_Addsat_fgINT32(void) {
  tstArith2d_Addsat(fgINT32,2000000000,2000000000);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Subsat(dtype,csat1,csat2)				\
									\
  dtype rawsrc1[] = {0, 5, 6, 7, 8, csat1, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat1, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat1, 0, 0, 9, 0,			\
		     0, 5, 6, 7, 8, csat1, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {0, 2, 2, 2, 2, csat2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, csat2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, csat2, 0, 0, 2, 0,			\
		     0, 2, 2, 2, 2, csat2, 0, 0, 2, 0};			\
									\
  dtype rawref[]  = {0, 3, 4, 5, 6,MIN_##dtype, 0, 0,7, 0,		\
		     0, 3, 4, 5, 6,MIN_##dtype, 0, 0,7, 0,		\
		     0, 3, 4, 5, 6,MIN_##dtype, 0, 0,7, 0,		\
		     0, 3, 4, 5, 6,MIN_##dtype, 0, 0,7, 0};		\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_subsat(dat, datsrc1, datsrc2);			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_subsat_str(dat2, datsrc1, #csat2);		\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Subsat_fgUINT8(void) {
  tstArith2d_Subsat(fgUINT8,200,220);
}
int testArith2d_Subsat_fgUINT16(void) {
  tstArith2d_Subsat(fgUINT16,40000,42000);
}
int testArith2d_Subsat_fgUINT32(void) {
  tstArith2d_Subsat(fgUINT32,3000000000U,3200000000U);
}
int testArith2d_Subsat_fgINT8(void) {
  tstArith2d_Subsat(fgINT8,-100,100);
}
int testArith2d_Subsat_fgINT16(void) {
  tstArith2d_Subsat(fgINT16,-20000,20000);
}
int testArith2d_Subsat_fgINT32(void) {
  tstArith2d_Subsat(fgINT32,-2000000000,2000000000);
}






/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Div(dtype)						\
									\
  dtype rawsrc1[] = {0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1};			\
									\
  dtype rawref[]  = {0, 3, 2, 1, 3, 7, 0, 0, 3, 0,			\
		     0, 3, 2, 1, 3, 7, 0, 0, 3, 0,			\
		     0, 3, 2, 1, 3, 7, 0, 0, 3, 0,			\
		     0, 3, 2, 1, 3, 7, 0, 0, 3, 0};			\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_div(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_div_str(dat2, datsrc1, "3");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Div_fgUINT8(void) {
  tstArith2d_Div(fgUINT8);
}
int testArith2d_Div_fgUINT16(void) {
  tstArith2d_Div(fgUINT16);
}
int testArith2d_Div_fgUINT32(void) {
  tstArith2d_Div(fgUINT32);
}
int testArith2d_Div_fgINT8(void) {
  tstArith2d_Div(fgINT8);
}
int testArith2d_Div_fgINT16(void) {
  tstArith2d_Div(fgINT16);
}
int testArith2d_Div_fgINT32(void) {
  tstArith2d_Div(fgINT32);
}
int testArith2d_Div_fgFLOAT32(void) {
  tstArith2d_Div(fgFLOAT32);
}
int testArith2d_Div_fgFLOAT64(void) {
  tstArith2d_Div(fgFLOAT64);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Mult(dtype)						\
									\
  dtype rawsrc1[] = {0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1};			\
									\
  dtype rawref[]  = {0,27,18, 9,27,63, 0, 0,27, 0,			\
		     0,27,18, 9,27,63, 0, 0,27, 0,			\
		     0,27,18, 9,27,63, 0, 0,27, 0,			\
		     0,27,18, 9,27,63, 0, 0,27, 0};			\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_mult(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_mult_str(dat2, datsrc1, "3");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Mult_fgUINT8(void) {
  tstArith2d_Mult(fgUINT8);
}
int testArith2d_Mult_fgUINT16(void) {
  tstArith2d_Mult(fgUINT16);
}
int testArith2d_Mult_fgUINT32(void) {
  tstArith2d_Mult(fgUINT32);
}
int testArith2d_Mult_fgINT8(void) {
  tstArith2d_Mult(fgINT8);
}
int testArith2d_Mult_fgINT16(void) {
  tstArith2d_Mult(fgINT16);
}
int testArith2d_Mult_fgINT32(void) {
  tstArith2d_Mult(fgINT32);
}
int testArith2d_Mult_fgFLOAT32(void) {
  tstArith2d_Mult(fgFLOAT32);
}
int testArith2d_Mult_fgFLOAT64(void) {
  tstArith2d_Mult(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Add(dtype)						\
									\
  dtype rawsrc1[] = {0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0,			\
		     0, 9, 6, 3, 9,21, 0, 0, 9, 0};			\
									\
  dtype rawsrc2[] = {1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1,			\
		     1, 3, 3, 3, 3, 3, 1, 1, 3, 1};			\
									\
  dtype rawref[]  = {1,12, 9, 6,12,24, 1, 1,12, 1,			\
		     1,12, 9, 6,12,24, 1, 1,12, 1,			\
		     1,12, 9, 6,12,24, 1, 1,12, 1,			\
		     1,12, 9, 6,12,24, 1, 1,12, 1};			\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_add(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_add_str(dat2, datsrc1, "3");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Add_fgUINT8(void) {
  tstArith2d_Add(fgUINT8);
}
int testArith2d_Add_fgUINT16(void) {
  tstArith2d_Add(fgUINT16);
}
int testArith2d_Add_fgUINT32(void) {
  tstArith2d_Add(fgUINT32);
}
int testArith2d_Add_fgINT8(void) {
  tstArith2d_Add(fgINT8);
}
int testArith2d_Add_fgINT16(void) {
  tstArith2d_Add(fgINT16);
}
int testArith2d_Add_fgINT32(void) {
  tstArith2d_Add(fgINT32);
}
int testArith2d_Add_fgFLOAT32(void) {
  tstArith2d_Add(fgFLOAT32);
}
int testArith2d_Add_fgFLOAT64(void) {
  tstArith2d_Add(fgFLOAT64);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Sub(dtype)						\
									\
  dtype rawsrc1[] = {5, 9, 6, 3, 9,21, 5, 5, 9, 5,			\
		     5, 9, 6, 3, 9,21, 5, 5, 9, 5,			\
		     5, 9, 6, 3, 9,21, 5, 5, 9, 5,			\
		     5, 9, 6, 3, 9,21, 5, 5, 9, 5};			\
									\
  dtype rawsrc2[] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3,			\
		     3, 3, 3, 3, 3, 3, 3, 3, 3, 3,			\
		     3, 3, 3, 3, 3, 3, 3, 3, 3, 3,			\
		     3, 3, 3, 3, 3, 3, 3, 3, 3, 3};			\
									\
  dtype rawref[]  = {2, 6, 3, 0, 6,18, 2, 2, 6, 2,			\
		     2, 6, 3, 0, 6,18, 2, 2, 6, 2,			\
		     2, 6, 3, 0, 6,18, 2, 2, 6, 2,			\
		     2, 6, 3, 0, 6,18, 2, 2, 6, 2};			\
									\
									\
  FLGR_Data2D *datsrc1, *datsrc2, *datref, *dat, *dat2;			\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datsrc2= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat2   = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datsrc2, rawsrc2);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_sub(dat, datsrc1, datsrc2);				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  ret=flgr2d_arith_const_sub_str(dat2, datsrc1, "3");			\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datsrc2);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
  flgr2d_destroy(dat2);							\
									\
  return 2


int testArith2d_Sub_fgUINT8(void) {
  tstArith2d_Sub(fgUINT8);
}
int testArith2d_Sub_fgUINT16(void) {
  tstArith2d_Sub(fgUINT16);
}
int testArith2d_Sub_fgUINT32(void) {
  tstArith2d_Sub(fgUINT32);
}
int testArith2d_Sub_fgINT8(void) {
  tstArith2d_Sub(fgINT8);
}
int testArith2d_Sub_fgINT16(void) {
  tstArith2d_Sub(fgINT16);
}
int testArith2d_Sub_fgINT32(void) {
  tstArith2d_Sub(fgINT32);
}
int testArith2d_Sub_fgFLOAT32(void) {
  tstArith2d_Sub(fgFLOAT32);
}
int testArith2d_Sub_fgFLOAT64(void) {
  tstArith2d_Sub(fgFLOAT64);
}








/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Atan(dtype)						\
									\
  dtype rawsrc1[] = {0, 10, 20, 20, 30, 0, 0, 0, 30, 0,			\
		     0, 10, 20, 20, 30, 0, 0, 0, 30, 0,			\
		     0, 10, 20, 20, 30, 0, 0, 0, 30, 0,			\
		     0, 10, 20, 20, 30, 0, 0, 0, 30, 0};		\
									\
  dtype rawref[]  = {0,147,152,152,153, 0, 0, 0,153, 0,			\
		     0,147,152,152,153, 0, 0, 0,153, 0,			\
		     0,147,152,152,153, 0, 0, 0,153, 0,			\
		     0,147,152,152,153, 0, 0, 0,153, 0};		\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_atan(dat, datsrc1);					\
  flgr2d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Atan_fgFLOAT32(void) {
  tstArith2d_Atan(fgFLOAT32);
}
int testArith2d_Atan_fgFLOAT64(void) {
  tstArith2d_Atan(fgFLOAT64);
}



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Asin(dtype)						\
									\
  dtype rawsrc1[] = {0, 0.2, 0.3, 0.4, 0.5, 0, 0, 0, 0.2, 0,		\
		     0, 0.2, 0.3, 0.4, 0.5, 0, 0, 0, 0.2, 0,		\
		     0, 0.2, 0.3, 0.4, 0.5, 0, 0, 0, 0.2, 0,		\
		     0, 0.2, 0.3, 0.4, 0.5, 0, 0, 0, 0.2, 0};		\
									\
  dtype rawref[]  = {0,  20,  30,  41,  52, 0, 0, 0,  20, 0,		\
		     0,  20,  30,  41,  52, 0, 0, 0,  20, 0,		\
		     0,  20,  30,  41,  52, 0, 0, 0,  20, 0,		\
		     0,  20,  30,  41,  52, 0, 0, 0,  20, 0};		\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_asin(dat, datsrc1);					\
  flgr2d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Asin_fgFLOAT32(void) {
  tstArith2d_Asin(fgFLOAT32);
}
int testArith2d_Asin_fgFLOAT64(void) {
  tstArith2d_Asin(fgFLOAT64);
}


/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Acos(dtype)						\
									\
  dtype rawsrc1[] = {  0, 0.2, 0.3, 0.4, 0.5,   0,   0,   0, 0.2,   0,	\
		       0, 0.2, 0.3, 0.4, 0.5,   0,   0,   0, 0.2,   0,	\
		       0, 0.2, 0.3, 0.4, 0.5,   0,   0,   0, 0.2,   0,	\
		       0, 0.2, 0.3, 0.4, 0.5,   0,   0,   0, 0.2,   0};	\
									\
  dtype rawref[]  = {157, 136, 126, 115, 104, 157, 157, 157, 136, 157,	\
		     157, 136, 126, 115, 104, 157, 157, 157, 136, 157,	\
		     157, 136, 126, 115, 104, 157, 157, 157, 136, 157,	\
		     157, 136, 126, 115, 104, 157, 157, 157, 136, 157};	\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_acos(dat, datsrc1);					\
  flgr2d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Acos_fgFLOAT32(void) {
  tstArith2d_Acos(fgFLOAT32);
}
int testArith2d_Acos_fgFLOAT64(void) {
  tstArith2d_Acos(fgFLOAT64);
}








/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Tan(dtype)						\
									\
  dtype rawsrc1[] = {0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0,		\
		     0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0,		\
		     0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0,		\
		     0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0};		\
									\
  dtype rawref[]  = {0,  10, 20,   30,  42, 0, 0, 0,  54, 0,		\
		     0,  10, 20,   30,  42, 0, 0, 0,  54, 0,		\
		     0,  10, 20,   30,  42, 0, 0, 0,  54, 0,		\
		     0,  10, 20,   30,  42, 0, 0, 0,  54, 0};		\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_tan(dat, datsrc1);					\
  flgr2d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Tan_fgFLOAT32(void) {
  tstArith2d_Tan(fgFLOAT32);
}
int testArith2d_Tan_fgFLOAT64(void) {
  tstArith2d_Tan(fgFLOAT64);
}






/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Sin(dtype)						\
									\
  dtype rawsrc1[] = {0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0,		\
		     0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0,		\
		     0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0,		\
		     0, 0.1, 0.2, 0.3, 0.4, 0, 0, 0, 0.5, 0};		\
									\
  dtype rawref[]  = {0,   9,  19,  29,  38, 0, 0, 0,  47, 0,		\
		     0,   9,  19,  29,  38, 0, 0, 0,  47, 0,		\
		     0,   9,  19,  29,  38, 0, 0, 0,  47, 0,		\
		     0,   9,  19,  29,  38, 0, 0, 0,  47, 0};		\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_sin(dat, datsrc1);					\
  flgr2d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Sin_fgFLOAT32(void) {
  tstArith2d_Sin(fgFLOAT32);
}
int testArith2d_Sin_fgFLOAT64(void) {
  tstArith2d_Sin(fgFLOAT64);
}





/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Cos(dtype)						\
							 		\
  dtype rawsrc1[] = {  0, 0.1, 0.2, 0.3, 0.4,   0,   0,   0, 0.5,   0,	\
		       0, 0.1, 0.2, 0.3, 0.4,   0,   0,   0, 0.5,   0,	\
		       0, 0.1, 0.2, 0.3, 0.4,   0,   0,   0, 0.5,   0,	\
		       0, 0.1, 0.2, 0.3, 0.4,   0,   0,   0, 0.5,   0};	\
									\
  dtype rawref[]  = {100,  99,  98,  95,  92, 100, 100, 100,  87, 100,	\
		     100,  99,  98,  95,  92, 100, 100, 100,  87, 100,	\
		     100,  99,  98,  95,  92, 100, 100, 100,  87, 100,	\
		     100,  99,  98,  95,  92, 100, 100, 100,  87, 100};	\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_cos(dat, datsrc1);					\
  flgr2d_arith_const_mult_str(dat, dat,"100");				\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Cos_fgFLOAT32(void) {
  tstArith2d_Cos(fgFLOAT32);
}
int testArith2d_Cos_fgFLOAT64(void) {
  tstArith2d_Cos(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Floor(dtype)						\
							 		\
  dtype rawsrc1[] = {1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5,	\
		     1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5,	\
		     1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5,	\
		     1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5};	\
									\
  dtype rawref[]  = {1,     9,   5,   3,   9,    8 ,7, 0,   0,   8,	\
		     1,     9,   5,   3,   9,    8 ,7, 0,   0,   8,	\
		     1,     9,   5,   3,   9,    8 ,7, 0,   0,   8,	\
		     1,     9,   5,   3,   9,    8 ,7, 0,   0,   8};	\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_floor(dat, datsrc1);					\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Floor_fgFLOAT32(void) {
  tstArith2d_Floor(fgFLOAT32);
}
int testArith2d_Floor_fgFLOAT64(void) {
  tstArith2d_Floor(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstArith2d_Ceil(dtype)						\
							 		\
  dtype rawsrc1[] = {1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5,	\
		     1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5,	\
		     1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5,	\
		     1.2, 9.1, 5.2, 3.3, 9.4, 8.99, 7, 0, 0.5, 8.5};	\
									\
  dtype rawref[]  = {  2,  10,   6,   4,  10,    9 ,7, 0,   1,   9,	\
		       2,  10,   6,   4,  10,    9 ,7, 0,   1,   9,	\
		       2,  10,   6,   4,  10,    9 ,7, 0,   1,   9,	\
		       2,  10,   6,   4,  10,    9 ,7, 0,   1,   9};	\
									\
									\
  FLGR_Data2D *datsrc1, *datref, *dat;					\
  FLGR_Ret ret;								\
									\
  datsrc1= flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  datref = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
  dat    = flgr2d_create_pixmap(10,4,1, flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(datsrc1, rawsrc1);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
									\
  ret=flgr2d_arith_ceil(dat, datsrc1);					\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc1);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int testArith2d_Ceil_fgFLOAT32(void) {
  tstArith2d_Ceil(fgFLOAT32);
}
int testArith2d_Ceil_fgFLOAT64(void) {
  tstArith2d_Ceil(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_TEST_ARITH_COMPLEX_MODULE_2D(dtype)			\
							 		\
  dtype rawsrc[] = {0.0,5.1, 32.2,-8.3, 1.0,1.0,  0.0,-3.0,  0.0,5.0,	\
		    2.0,9.1, 55.2,10.3,-1.0,0.0,  8.0, 5.0,  0.0,7.0,	\
		   -7.0,2.1, -0.2,-9.3, 0.4,0.0, -2.0,-5.0,  0.0,6.0,	\
		   -5.0,3.1, 10.2,10.3, 0.4,0.9,  4.0,-9.0, -0.0,5.0}; \
									\
  dtype rawref[]  = {5,  33,  1,  3,  5,				\
		     9,  56,  1,  9,  7,				\
		     7,   9,  0,  5,  6,				\
		     5,  14,  0,  9,  5};				\
									\
									\
  FLGR_Data2D *datsrc, *datref, *dat;					\
  FLGR_Ret ret;								\
  FLGR_Type type = flgr_get_type_from_string(#dtype);			\
									\
  datsrc  = flgr2d_create_pixmap(4, 5, 2, type);			\
  datref  = flgr2d_create_pixmap(4, 5, 1, type);			\
  dat     = flgr2d_create_pixmap(4, 5, 1, type);			\
									\
  flgr2d_import_raw_ptr(datsrc, rawsrc);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
  									\
  ret=flgr2d_arith_complex_module(dat, datsrc);				\
									\
  flgr2d_arith_floor(dat,dat);						\
									\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int test_flgr2d_arith_complex_module_fgFLOAT32(void) {
  FLGR_MACRO_TEST_ARITH_COMPLEX_MODULE_2D(fgFLOAT32);
}
int test_flgr2d_arith_complex_module_fgFLOAT64(void) {
  FLGR_MACRO_TEST_ARITH_COMPLEX_MODULE_2D(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_TEST_ARITH_COMPLEX_ARGUMENT_2D(dtype)		\
							 		\
  dtype rawsrc[] = {0.0,5.1, 32.2,-8.3, 1.0,1.0,  0.0,-3.0,  0.0,5.0,	\
		    2.0,9.1, 55.2,10.3,-1.0,0.0,  8.0, 5.0,  0.0,7.0,	\
		   -7.0,2.1, -0.2,-9.3, 0.4,0.0, -2.0,-5.0,  0.0,6.0,	\
		   -5.0,3.1, 10.2,10.3, 0.4,0.9,  4.0,-9.0, -0.0,5.0};  \
									\
  dtype rawref[]  = {1,  -1,  0, -2,  1,				\
		     1,   0,  3,  0,  1,				\
		     2,  -2,  0, -2,  1,				\
		     2,   0,  1, -2,  1};				\
									\
									\
  FLGR_Data2D *datsrc, *datref, *dat;					\
  FLGR_Ret ret;								\
  FLGR_Type type = flgr_get_type_from_string(#dtype);			\
									\
  datsrc  = flgr2d_create_pixmap(4, 5, 2, type);			\
  datref  = flgr2d_create_pixmap(4, 5, 1, type);			\
  dat     = flgr2d_create_pixmap(4, 5, 1, type);			\
									\
  flgr2d_import_raw_ptr(datsrc, rawsrc);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
  									\
  ret=flgr2d_arith_complex_argument(dat, datsrc);			\
									\
  flgr2d_arith_floor(dat,dat);						\
									\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datsrc);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int test_flgr2d_arith_complex_argument_fgFLOAT32(void) {
  FLGR_MACRO_TEST_ARITH_COMPLEX_ARGUMENT_2D(fgFLOAT32);
}
int test_flgr2d_arith_complex_argument_fgFLOAT64(void) {
  FLGR_MACRO_TEST_ARITH_COMPLEX_ARGUMENT_2D(fgFLOAT64);
}




/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define FLGR_MACRO_TEST_ARITH_COMPLEX_BUILD_2D(dtype)			\
							 		\
  dtype rawref[] = {-0.0,6.0, 33.0,-8.0, 2.0,1.0, -0.0,-3.0, -0.0,5.0,	\
		    3.0,10.0, 56.0,11.0, -0.0,-0.0, 8.0,6.0, -0.0,7.0,	\
		    -6.0,3.0, -0.0,-9.0, 1.0,0.0, -1.0,-5.0, -0.0,6.0,	\
		    -5.0,4.0, 11.0,11.0, 1.0,1.0, 4.0,-9.0, -0.0,5.0};	\
									\
  dtype module[]  = {5.100, 33.253, 1.414, 3.100, 5.000,		\
		     9.317, 56.153, 1.000, 9.434, 7.000,		\
		     7.308,  9.302, 0.400, 5.385, 6.000,		\
		     5.883, 14.496, 0.985, 9.849, 5.000};		\
  									\
  dtype argument[]  = {1.571, -0.252, 0.785, -1.571, 1.571,		\
		       1.354,  0.184, 3.142,  0.559, 1.571,		\
		       2.850, -1.592, 0.000, -1.951, 1.571,		\
		       2.587,  0.790, 1.153, -1.153, 1.571};		\
									\
									\
  FLGR_Data2D *datmod, *datarg, *datref, *dat;				\
  FLGR_Ret ret;								\
  FLGR_Type type = flgr_get_type_from_string(#dtype);			\
									\
  datmod  = flgr2d_create_pixmap(4, 5, 1, type);			\
  datarg  = flgr2d_create_pixmap(4, 5, 1, type);			\
  datref  = flgr2d_create_pixmap(4, 5, 2, type);			\
  dat     = flgr2d_create_pixmap(4, 5, 2, type);			\
									\
  flgr2d_import_raw_ptr(datmod, module);				\
  flgr2d_import_raw_ptr(datarg, argument);				\
  flgr2d_import_raw_ptr(datref, rawref);				\
  									\
  ret=flgr2d_arith_complex_build(dat, datmod, datarg);			\
									\
  flgr2d_arith_ceil(dat,dat);						\
									\
  check_and_display_data2d(datref, dat, ret);				\
									\
  flgr2d_destroy(datmod);						\
  flgr2d_destroy(datarg);						\
  flgr2d_destroy(datref);						\
  flgr2d_destroy(dat);							\
									\
  return 1


int test_flgr2d_arith_complex_build_fgFLOAT32(void) {
  FLGR_MACRO_TEST_ARITH_COMPLEX_BUILD_2D(fgFLOAT32);
}
int test_flgr2d_arith_complex_build_fgFLOAT64(void) {
  FLGR_MACRO_TEST_ARITH_COMPLEX_BUILD_2D(fgFLOAT64);
}

